package com.kefu.client.services.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.kefu.client.services.ClientServices;
import com.kefu.dao.ClientUserMapper;
import com.kefu.dao.SystemUserMapper;
import com.kefu.model.ClientUser;
import com.kefu.model.SystemUser;
@Service
public class ClientServicesImpl implements ClientServices {

	@Autowired
	private ClientUserMapper clientUserMapper;
	@Autowired
	private SystemUserMapper systemUserMapper;
	
	public ClientUser saveUserInfo(ClientUser user) {
		if(clientUserMapper.insert(user)==1)return clientUserMapper.selectByUserUUID(user.getUuid());
		return null;
	}

	@Override
	public List<SystemUser> findOnLineSystemUsers() {
		return systemUserMapper.findOnLineSystemUsers();
	}

	@Override
	public int checkClientUid(String uid) {
		return clientUserMapper.countByUid(uid);
	}

	@Override
	public void setStateByUid(String uid, String state){
		clientUserMapper.updateStateByUid(uid,state);
	}


	public void updateSystemCustomUser(SystemUser su, int i) {
		systemUserMapper.updateSystemCustomUser(su.getId(),i);
	}

	@Override
	public ClientUser selectClientUserByUid(String uid) {
		// TODO Auto-generated method stub
		return clientUserMapper.selectByUserUUID(uid);
	}

	@Override
	public void updateClientUserById(ClientUser cu) {
		clientUserMapper.updateByPrimaryKey(cu);
	}

}
